package com.yunxin.core.application.dto.order;

import com.yunxin.core.domain.external.product.ProductAllocationDetail;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
public class  BalanceProduct implements Serializable {

    private Long productId;
    private Integer totalLimit;

    public BalanceProduct(Long productId, Integer totalLimit) {
        this.productId = productId;
        this.totalLimit = totalLimit;
    }

    public BalanceProduct(ProductAllocationDetail detail) {
        this.productId = detail.getProductId();
        this.totalLimit = detail.getTotalLimit();
    }

    public static List<BalanceProduct> buildList(List<ProductAllocationDetail> details) {
        List<BalanceProduct> products = new ArrayList<BalanceProduct>();
        for (ProductAllocationDetail detail : details) {
            products.add(new BalanceProduct(detail));
        }
        return products;
    }
}